<template>
    <div>
        <div data-role="page" id="pageone">
	<section class="part-user-info">
		<div class="top-info">
			<div class="users left">
				<div class="head-portrait">
					<img :src="accountinfo.headimgurl" alt="">
				</div>
				<div class="login-reg" style="width: 201px; height: 19px;overflow: hidden;text-align: left;white-space: nowrap;text-overflow: ellipsis;">
				{{accountinfo.nickname}}
				</div>
				<div class="login-reg">
					ID:00{{accountinfo.id}}
				</div>
			</div>
      <div class="change-identity">
        <div class="business">
					 <!-- <a v-if="tjrList=='此用户 查询不到上级'" @click="hint"   class="shangjia_mine">
            <i class="icon"></i>
            <p class="text">商家</p>
          </a> -->
          <router-link v-if="0==accountinfo.userCompanyType" :to="{name:'Business_rzxzy'}"  class="shangjia_mine"><!--Business_rzxzy-->
            <i class="icon"></i>
            <p class="text">商家</p>
          </router-link>
          <router-link v-else-if="0==accountinfo.companyStatus" :to="{name:'shenhezhong'}"  class="shangjia_mine">
            <i class="icon"></i>
            <p class="text">商家</p>
          </router-link>
		  <router-link v-else-if="2==accountinfo.companyStatus" :to="{name:'shibai',params:{id:companyId}}"  class="shangjia_mine">
            <i class="icon"></i>
            <p class="text">商家</p>
          </router-link>
		  <router-link v-else @click.native="oderback()" to  class="shangjia_mine" >
            <i class="icon"></i>
            <p class="text">商家</p>
          </router-link>
        </div>
        <span class="line"></span>
        <div class="personal">
          <router-link :to="{name:'Mine'}" data-ajax="false">
            <i class="icon"></i>
            <p class="text">个人</p>
          </router-link>
        </div>
      </div>
		</div>
		<div class="bottom-info">
      <p class="xj-shouyi">个人资产（元）</p>
     <router-link :to="{name:'earnings_mx'}" style="color: #ffffff;" v-show="false">
			  <p class="shouyi-mx" >查看资产明细> </p>
      </router-link>
		</div>

		<div class="user-num">
			<div class="left">
				<p class="number">{{money.userBalance | amountMin100(2)}}</p>
        <router-link :to="{name:'cash_earnings'}" style="color: #ffffff;"><!--:to="{name:'cash_earnings'}"-->
				  <p class="con-text">现金收益</p>
        </router-link>
			</div>
			<div class="line" ></div>
      <router-link :to="{name:'hb_earning'}" style="color: #ffffff;" class="dingwei">
			<div class="right">
				<p class="number">{{money.userScore | amountMin100(2)}}</p><!--:to="{name:'hb_earning'}"-->
        <router-link :to="{name:'hb_earning'}" style="color: #ffffff;">
          <p class="con-text" >购物红包</p>
        </router-link>
			</div>
      </router-link>
		</div>
	</section>
	<!--商家订单-->
	<section class="business-order">
		<div class="top-info">
			<span class="left-text">个人订单</span>
			<router-link :to="{name:'personorder_r'}" class="more-order" data-ajax="false">查看更多订单> </router-link>
		</div>
		<div class="bottom-info">
			<div class="same-box same-box1">
				<router-link :to="{name:'personorder_r',query:{id:0}}">
					<i class="icon"></i>
						<span class="icon1" v-if="dfk>0">{{dfk}}</span>
					<p class="text" style="text-align:center;">待付款</p>
				</router-link>
			</div>
			<div class="same-box same-box2">
				<router-link :to="{name:'personorder_r',query:{id:1}}">
					<i class="icon"></i>
						<span class="icon1" v-if="yfk>0">{{yfk}}</span>
					<p class="text" style="text-align:center;">已付款</p>
				</router-link>
			</div>
			<div class="same-box same-box3">
				<router-link :to="{name:'personorder_r',query:{id:2}}">
					<i class="icon"></i>
					<span class="icon1" v-if="pingjia>0">{{	pingjia}}</span>
					<p class="text" style="text-align:center;">评价</p>
				</router-link>
			</div>
			<div class="same-box same-box4" @click="shouhou">
				<router-link :to="{name:'Mine'}">
					<i class="icon"></i>
					<p class="text" style="text-align:center;">售后</p>
				</router-link>
			</div>
		</div>
	</section>

	<!-- <ul>
	<li></li>
	</ul> -->
	<section class="mine-setinfo">
	<ul class="list-ul">
			<router-link :to="{name:'Userinfo_bg',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon" >
			<li class="list-li">
				<!-- <i class="l-icon l-icon1"></i> -->
				<span>
				<img src="../images/shouji.png">
				</span >
				<span class="span1">手机号</span>
				<span class="num" id="tel">{{this.tel}}</span>
				<router-link :to="{name:'Userinfo_bg',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
			</router-link>
				<router-link :to="{name:'Userinfo_bg',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon" >
			<li class="list-li">
				<!-- <i class="l-icon l-icon1"></i> -->
				<span>
				<img src="../images/weixin.png">
				</span>
				<span class="span1">微信号</span>
				<span class="num" id="tel">{{this.wechatid}}</span>
				<router-link :to="{name:'Userinfo_bg',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
			</router-link>
			</ul>
	</section>
	<!--设置-->
	<section class="mine-setinfo">
		<ul class="list-ul">
				<router-link :to="{name:'Personqrcodetg',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon" >
			<li class="list-li">
				<!-- <i class="l-icon l-icon1"></i> -->
				<span>
				<img src="../images/tuiguang.png">
				</span>
				<span class="span1">我要推广</span>
				<router-link :to="{name:'Personqrcodetg',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
			</router-link>


             	<!-- <router-link  :to="{path:'new_vitacart'}" data-transition="slide" class="href-icon" >
			<li class="list-li">
				<span>
				<img src="../images/5ba002602055a5b3a4106259673c5fb.png">
				</span>
				<span class="span1">我的卡劵</span>
				<router-link :to="{path:'new_vitacart'}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
			</router-link> -->



			<!-- <a href="/wap/qrcodepeoplepay.html" class="href-icon" v-else>
			<li class="list-li">v-if="accountinfo.qrPay==2"
				<i class="l-icon l-icon1"></i>
				<span class="span1">二维码</span>
					<a href="/wap/qrcodepeoplepay.html" class="href-icon">
					<i class="icon"></i>
			</a> -->
			<!-- </li> -->
			<!-- </a> -->
     	     <router-link :to="{name:'member',query:{level:3}}" data-transition="slide" class="href-icon" v-if="1==tujianrenStyle">
			  	<li class="list-li">
					<i class="l-icon l-icon10"></i>
					<span class="span1">推荐人</span>
					<!-- <router-link :to="{name:'member',query:{level:3}}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
					</router-link> -->
					<span class="num">
						<span>{{tuijian.nickname}}</span>
					</span>
				  <a href="#pagethree" data-transition="slide" class="href-icon">
				 	<i class="icon"></i>
			   	</a>
			   	</li>
			</router-link>
			<router-link :to="{name:'Mine'}" data-transition="slide" class="href-icon"  v-else>
				<li class="list-li">
					<i class="l-icon l-icon10"></i>
					<span class="span1">推荐人</span>
					<span class="num">
						<span>{{tuijian.msg}}</span>
					</span>
				  <a href="#pagethree" data-transition="slide" class="href-icon">
				 	<i class="icon"></i>
			   	</a>
				</li>
			</router-link>
			<router-link :to="{name:'member',query:{level:1}}">
			<li class="list-li">
				<i class="l-icon l-icon2"></i>
				<span class="span1">直推会员</span>
				<span class="num">{{accountinfo.directNum}}</span>
				<a href="#pagethree" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</a>
			</li>
				</router-link>
			<router-link :to="{name:'member',query:{level:2}}">
			<li class="list-li" >
				<i class="l-icon l-icon3"></i>
				<span class="span1">间推会员</span>
				<span class="num">{{accountinfo.indirectNum}}</span>
				<a href="#pagefour" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</a>
			</li>
			</router-link>
			</ul>
			</section>

	<!--设置-->
	           <section class="mine-setinfo">
			   <ul class="list-ul">

				<router-link :to="{name:'',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon" v-if="2==accountinfo.qrPay">
			  <li class="list-li">
				<!-- <i class="l-icon l-icon1"></i> -->
				<span>
				<img src="../images/shengji.png">
				</span>
				<span class="span1">您已是高级合伙人</span>
				<router-link :to="{name:'',query:{id:accountinfo.id,nickname:accountinfo.nickname,qrPay:accountinfo.qrPay,style:1}}" data-transition="slide" class="href-icon" style="width: 12rem; text-align:right">
						<span class="num">
						<span> 编号为：{{accountinfo.selectForBh}}</span>
					</span>
					<!-- <i class="icon"></i> -->
				</router-link>
			</li>
			</router-link>
				<router-link to  @click.native="mine_else" data-transition="slide" class="href-icon" v-else>
			  <li class="list-li" >
				<!-- <i class="l-icon l-icon1"></i> -->
				<span>
				<img src="../images/shengji.png">
				</span>
				<span class="span1">升级高级合伙人</span>
				<router-link to data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
			</router-link>

			<router-link :to="{name:'Commodity_details_list'}" data-transition="slide" class="href-icon">
			<li class="list-li ">
				<i class="l-icon l-icon4"></i>
				<span class="span1">购物清单</span>
				<span class="num">{{listCount}}</span>
				<a  data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</a>
			</li>
		</router-link>
				<router-link :to="{name:'Userinfo_bg'}" data-transition="slide" class="href-icon" >
			<li class="list-li list-li-zk mar">
				<i class="l-icon l-icon5"></i>
				<span class="span1">个人资料</span>
				<router-link :to="{name:'Userinfo_bg'}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
				</router-link>
				<router-link :to="{name:'User_set'}" data-transition="slide" class="href-icon">
			<li class="list-li">
				<i class="l-icon l-icon6"></i>
				<span class="span1">关于首象商城</span>
				<router-link :to="{name:'User_set'}" data-transition="slide" class="href-icon">
					<i class="icon"></i>
				</router-link>
			</li>
			</router-link>
			<li class="list-li" @click="accounts_securityHref">
				<i class="l-icon l-icon6" id="icom"></i>
				<span class="span1">账户与安全</span>
					<i class="icon" ></i>
			</li>
       <li class="list-li mbz" @click="shouyiguize">
         <i class="l-icon l-icon6"></i>
         <span class="span1">收益规则</span>
         <i class="icon" ></i>
       </li>
		</ul>
	</section>
	<PhoneVerification ref="PhoneVerification" @getMessage="getVal"></PhoneVerification>
	<section class="zhanwei"></section>
</div>
<navFooter :pageName="pageName"></navFooter>
    </div>
</template>
<style scoped>
  @import "../../../assets/personal/css/mine.css";
  .mbz{
	  margin-bottom: 60px;
  }
	#icom{
		background: url("../../../assets/personal/images/anquan.png")no-repeat ;
		background-size: 100% 100%;
	}
</style>
<script>
import navFooter from '@/components/footer'
import PhoneVerification from '@/components/PhoneVerification'

export default {
components: {
   navFooter,
   PhoneVerification
  },
  data(){
	  return{
			///api/wallet?userId=1&page=1&rows=1
			pingjia:'',
      pageName:"personalmine",
		   list:{},
		   companyStatus:null,
		   accountinfo:{
       },
		   money:{userAmount:0,userScore:0},
			 companyId:"",
			 tjrList:"",
			 listCount:'',
			 yfk:'',
			 dfk:'',
			 checkBinded:'',
			 msg: '操作成功啦',
			tujianrenStyle:1,
			 PhoneVerificationStyle:'',//这是子组件传来的值
             accountinfo:[],
			  wechatid:'',
							tel:'',
							tuijian:[],
	  }
	},
	  beforeCreate(){
    //  console.log("获取fk前");
     var fk = this.$route.query.fk;
      if(!!fk && /^\d+-\d+-\d+-no-\d+$/g.test(fk)){
          var ar = fk.split("-");
          window.localStorage.headid= ar[ar.length-1];
       }
  },
	mounted(){
    console.log(window.localStorage.headid)
		this.chkmobilebind();
		this.loadaccoutinfo();
		this.referee();
		this.OrderCount();
		this.pinglun();
		this.daifukan();
		this.yifukuan();
		this.tujianren();
		this.info();
		this.getwxconfig();
  },
  methods:{
    getwxconfig(){
      var vm= this;
      console.log(vm);
      console.log(vm.accountinfo.headimgurl);
      this.$http.get(this.APIURL_PREFIX+"/api/wxs/config?url="+escape(location.href.split('#')[0])).then((response) => {
        console.log(response.data);
      var appid = 'wx488ae3f57360b7ea';
      wx.config({
        debug: false,
        appId: appid,
        timestamp: response.data.data.timestamp,
        nonceStr: response.data.data.noncestr,
        signature: response.data.data.signature,
        jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone','scanQRCode']
      });
      wx.ready(function(){
        wx.onMenuShareTimeline({
          title: vm.accountinfo.nickname,
          link: "http://"+window.location.host+"/wap/wx/login?fk=1-37-"+localStorage.headid+"-0",
          imgUrl:vm.accountinfo.headimgurl,
          desc:"个人中心",
          success: function () {
          },
          cancel: function () {
          }
        });
        wx.onMenuShareAppMessage({
          title: vm.accountinfo.nickname,
          link: "http://"+window.location.host+"/wap/wx/login?fk=1-37-"+localStorage.headid+"-0",
          imgUrl:vm.accountinfo.headimgurl,
          desc:"个人中心",
          success: function () {
          },
          cancel: function () {
          }
        });
        wx.onMenuShareQQ({
          title: vm.accountinfo.nickname,
          link: "http://"+window.location.host+"/wap/wx/login?fk=1-37-"+localStorage.headid+"-0",
          imgUrl:vm.accountinfo.headimgurl,
          desc:"个人中心",
          success: function () {
          },
          cancel: function () {
          }
        });
        wx.onMenuShareWeibo({
          title: vm.accountinfo.nickname,
          link: "http://"+window.location.host+"/wap/wx/login?fk=1-37-"+localStorage.headid+"-0",
          imgUrl:vm.accountinfo.headimgurl,
          desc:"个人中心",
          success: function () {
          },
          cancel: function () {
          }
        });
        wx.onMenuShareQZone({
          title: vm.accountinfo.nickname,
          link: "http://"+window.location.host+"/wap/wx/login?fk=1-37-"+localStorage.headid+"-0",
          imgUrl:vm.accountinfo.headimgurl,
          desc:"个人中心",
          success: function () {
          },
          cancel: function () {
          }
        });

      });
    }).catch(function(err){
        console.log(err)
      });

    },
		 mine_else(){
      window.location.href="/wap/qrcodeguize.html"
		 },
	    info: function(){
            this.$http.get(this.APIURL_PREFIX+'/api/wap/accounts/info').then((response) => {
				// console.log(response)
				this.accountinfo =response.data.data;
				this.tel=this.accountinfo.phone;
				this.wechatid=this.accountinfo.wechatId;
				// console.log(this.wechatid)
        //         console.log(this.tel)
				// console.log(this.accountinfo)

            }).catch(function(err){
                // console.log(err)
            });
        },
	  accounts_securityHref:function(){
		    this.$refs.PhoneVerification.childMethod();
            // console.log(this.PhoneVerificationStyle+"1112222333")
            if("成功"==this.PhoneVerificationStyle){
				this.$router.push({ name: 'accounts_security'})
			}else{

			}
	  },
    shouyiguize:function(){
      window.location='/wap/gongxiangtong/business/user_center/profit_gz.html';
    },
	   getVal(msg){//msg就是传过来的数据了  这只是个形参  名字可以随意
         this.PhoneVerificationStyle=msg;//然后将数据赋值给
			 },
			//  新增推荐人放外边
	tujianren(){
		this.$http.get(this.APIURL_PREFIX+'/api/wap/user/superior').then((response) => {
			if("此用户 查询不到上级"==response.data.msg){
			  	this.tujianrenStyle=2
				 this.tuijian=response.data
				//  console.log(this.tuijian.msg)
			  //  console.log("您没有推荐人")
				this.tujianrenStyle=2
			}else{
				 this.tuijian=response.data.data
				this.tujianrenStyle=1
			}
		}).catch(function(err){
		// console.log(err)
		})
	},
	oderback(){
	sessionStorage.removeItem('sess')
	// this.$router.push({name:'Business'})
		this.$router.push({name:'me_index'})

	},
daifukan(){
      this.$http.get(this.APIURL_PREFIX+'/api/wap/selectForOrderCount',{params:{payStatus:0}}).then((response) => {
				   this.dfk=response.data.data
          //  console.log(this.pingjia+"sdas")
		  	}).catch(function(err){
            	// console.log(err)
        })
		},
		yifukuan(){
       this.$http.get(this.APIURL_PREFIX+'/api/wap/selectForOrderCount',{params:{payStatus:1,orderStatus:1}}).then((response) => {
				   this.yfk=response.data.data
          //  console.log(this.pingjia+"sdas")
		  	}).catch(function(err){
            	// console.log(err)
        })
		},
		pinglun(){
        this.$http.get(this.APIURL_PREFIX+'/api/wap/selectForPjOrderCount',{params:{orderStatus:2}}).then((response) => {
					// console.log(response)
				   this.pingjia=response.data.data
          //  console.log(this.pingjia+"sdas")
		  	}).catch(function(err){
            	// console.log(err)
        })
		},
		dpj:function(){
       layer.msg("暂无评价")
		},
		hint:function(){
       layer.msg("此用户查询不到上级")
		},
		shouhou:function(){
       layer.msg("暂未开通")
		},
		chkmobilebind() {
				// console.log(111);
				this.$http.get(this.APIURL_PREFIX + "/api/wap/accounts/checkBinded").then((response) => {
						// console.log("查看是否绑定手机");
						// console.log(response.data)
						this.checkBinded=response.data.msg
						// console.log("checkBinded",this.checkBinded )
				}).catch(function (err) {
						// console.log(err)
				});
		},
		nav:function(){
			//   console.log(Status)
			//   this.companyStatus=status
				this.$http.get(this.APIURL_PREFIX+'/api/wap/companyInfo').then((response) => {
				  if(0==response.data.code){
						this.list =response.data.data[0].companyStatus;
          }
				}).catch(function(err){
					// console.log(err)
				});
		},
		referee(){///api/wap/user/superior
        this.$http.get(this.APIURL_PREFIX+'/api/wap/user/superior').then((response) => {
				this.tjrList=response.data.msg
	    	}).catch(function(err){
	     	// console.log(err)
		})
		},

		OrderCount(){//购物车个数
        this.$http.get(this.APIURL_PREFIX+'/api/shoppingCart/count').then((response) => {
					 this.listCount=response.data.data
	    	}).catch(function(err){
	     	// console.log(err)
				})

		},
		loadaccoutinfo: function(){
			this.$http.get(this.APIURL_PREFIX+'/api/wap/accounts/info').then((response) => {
        if(0==response.data.code){
					this.accountinfo =response.data.data;
					this.companyId=this.accountinfo.companyId;
					this.loadwalletinfo();
        }
				}).catch(function(err){
					// console.log(err)
				}).then();

		},
		loadwalletinfo: function(){
			this.$http.get(this.APIURL_PREFIX+"/api/wallet").then((response) => {
				if(0==response.data.code) {
					if(0==response.data.data.length){
						this.money={userAmount:0,userScore:0};
					}
					else{
						this.money = response.data.data;
						// console.log(this.money)
					}
				}
			}).catch(function(err){
				// console.log(err)
			});
		},
    loadzhituinum(){

    },
    loadjiantuinum(){

    }

  }
}
</script>

